﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Cinchoo.Core.IO;
using Cinchoo.Core.Collections;
using System.IO;
using System.Collections;
using System.Data.SqlClient;
using System.Threading;
using System.Data;
using System.Text.RegularExpressions;

namespace Cinchoo.Core.ETL
{
    public abstract class ChoETLBaseDbCommandJob : ChoETLBaseDbCommandTask
    {
        public ChoETLBaseDbCommandJob(string connectionString, string sql) : base(connectionString, sql)
        {
        }

        public ChoETLBaseDbCommandJob(IDbConnection connection, string sql, IDbTransaction trans = null)
            : base(connection, sql, trans)
        {
        }

        public override IEnumerable<IEnumerable<ChoETLObject>> Run(IEnumerable<IEnumerable<ChoETLObject>> lists)
        {
            lists = (IEnumerable<IEnumerable<ChoETLObject>>)IChoEnumerableEx.Loop<ChoETLObject>(lists);
            this.ExecuteTask();
            return base.Run(lists);
        }

        protected virtual void ExecuteTask()
        {
            _command.ExecuteNonQuery();
        }
    }
}
